package com.itheima.demo4;

public class Producer implements Runnable{


    @Override
    public void run() {
        while(true) {
            synchronized (Box.lock) {
                    if (Box.milk) {
                        try {
                            Box.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }

                        Box.setMilk(true);
                        Box.setX(Box.x+ 1);
                        System.out.println("存储牛奶" + Box.x + "瓶");
                        Box.lock.notifyAll();
                    }
            }

    }
}
